package com.bojin.studio.ubattery.advice;

import java.util.List;

import android.content.Context;
import android.net.ConnectivityManager;

import com.bojin.studio.ubattery.ControlManager;
import com.bojin.studio.ubattery.R;
import com.bojin.studio.ubattery.adviceInfo;

public class DataAdvice {
	
Context context=null;
	
	public DataAdvice(Context mcontext)
	{
		context=mcontext;
	}
	
	public void detect(List<adviceInfo> adviceList)
	{
        ConnectivityManager conMan = (ConnectivityManager) context.getSystemService (Context.CONNECTIVITY_SERVICE); 		
	    boolean mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected(); 
	    boolean wifi = conMan.getNetworkInfo (ConnectivityManager.TYPE_WIFI).isConnected();
	    ControlManager cm=new ControlManager(context);
	    
	    if(wifi==true&&cm.getMobileState()==true)
	    {
	    	adviceInfo adInfo=new adviceInfo();
			adInfo.icon=context.getResources().getDrawable(R.drawable.stat_sys_data_inandout_h);
			adInfo.title=context.getResources().getString(R.string.t_mobileconnect);
			adInfo.action="Turn off mobile switch";
			adInfo.reason="Wifi connection is already connected";
			adInfo.content="Please Turn off mobile switch";
			adviceList.add(adInfo);
	    }	    
	    else if(mobile==false&&cm.getMobileState()==true)
	    {
	    	adviceInfo adInfo=new adviceInfo();
			adInfo.icon=context.getResources().getDrawable(R.drawable.stat_sys_data_inandout_h);
			adInfo.title=context.getResources().getString(R.string.t_mobileconnect);
			adInfo.action="Turn off mobile switch";
			adInfo.reason="Mobile connection is already disconnected";
			adInfo.content="Mobile disconnect";
			adviceList.add(adInfo);
	    }
		
	}

}
